package com.example.springboothello.controller;


import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/hello")
public class HelloController {
    private static HashMap<Integer ,String > hashMap=new HashMap<>();
    @PostMapping("/{id}/{name}")
    public String add(@PathVariable Integer id,@PathVariable String name){
        hashMap.put(id,name);
        return id+"///"+name+"增加成功现在为"+hashMap;
    }
    @GetMapping
    public String get(){
        return "查找成功现在为"+hashMap;
    }
    @DeleteMapping("{id}")
    public String del(@PathVariable Integer id){
        hashMap.remove(id);
        return "删除成功现在为"+hashMap;
    }
    @PutMapping("/{id}/{name}")
    public String change(@PathVariable Integer id,@PathVariable String name){
        hashMap.put(id,name);
        return "修改成功现在为"+hashMap;
    }
}
